cmake_minimum_required(VERSION 3.25)

project(radar_detect)
set(BUILD_PROJECT_NAME radar_detect)
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_FLAGS_COMMON_DEBUG "-O0 -DDEBUG -g -Wall")
set(CMAKE_FLAGS_COMMON_RELEASE "-Os")

set(CMAKE_C_FLAGS_DEBUG ${CMAKE_FLAGS_COMMON_DEBUG})
set(CMAKE_C_FLAGS_RELEASE ${CMAKE_FLAGS_COMMON_RELEASE})
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_FLAGS_COMMON_DEBUG})
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_FLAGS_COMMON_RELEASE})

set(SRC_LIST
  ${CMAKE_CURRENT_SOURCE_DIR}/bus/park.h
  ${CMAKE_CURRENT_SOURCE_DIR}/bus/park.c
  ${CMAKE_CURRENT_SOURCE_DIR}/common/os_sys.c
  ${CMAKE_CURRENT_SOURCE_DIR}/common/os_sys.h
  ${CMAKE_CURRENT_SOURCE_DIR}/param/param.c
  ${CMAKE_CURRENT_SOURCE_DIR}/param/param.h
  ${CMAKE_CURRENT_SOURCE_DIR}/easylogger/inc/elog_cfg.h
  ${CMAKE_CURRENT_SOURCE_DIR}/easylogger/inc/elog_port.h
  ${CMAKE_CURRENT_SOURCE_DIR}/easylogger/inc/elog.h
  ${CMAKE_CURRENT_SOURCE_DIR}/easylogger/port/elog_port.c
  ${CMAKE_CURRENT_SOURCE_DIR}/easylogger/src/elog_async.c
  ${CMAKE_CURRENT_SOURCE_DIR}/easylogger/src/elog_buf.c
  ${CMAKE_CURRENT_SOURCE_DIR}/easylogger/src/elog_utils.c
  ${CMAKE_CURRENT_SOURCE_DIR}/easylogger/src/elog.c
  ${CMAKE_CURRENT_SOURCE_DIR}/log/log_file.c
  ${CMAKE_CURRENT_SOURCE_DIR}/log/log_file.h
  ${CMAKE_CURRENT_SOURCE_DIR}/log/log_id_def.h
  ${CMAKE_CURRENT_SOURCE_DIR}/log/vz_log.h
  ${CMAKE_CURRENT_SOURCE_DIR}/log/vz_log.c
  ${CMAKE_CURRENT_SOURCE_DIR}/common/app_main.h
  ${SRC_LIST}
)

set(INC_PATH
  ${CMAKE_CURRENT_SOURCE_DIR}/bus
  ${CMAKE_CURRENT_SOURCE_DIR}/common
  ${CMAKE_CURRENT_SOURCE_DIR}/param
  ${CMAKE_CURRENT_SOURCE_DIR}/easylogger/inc
  ${CMAKE_CURRENT_SOURCE_DIR}/easylogger/port
  ${CMAKE_CURRENT_SOURCE_DIR}/log
  ${INC_PATH})

file(GLOB FOLDER_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/*.c" "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
set(SRC_LIST ${SRC_LIST} ${FOLDER_SRC_LIST})

set(INC_PATH ${INC_PATH} "${CMAKE_CURRENT_SOURCE_DIR}")

include_directories(${INC_PATH})

foreach(SRC_FILE ${SRC_LIST})
  message(STATUS "    add source file ='${SRC_FILE}'")
endforeach()

add_library(${BUILD_PROJECT_NAME} SHARED ${SRC_LIST})
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
